package niuke;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class 数列还原 {

    static int n = 0,k=0;
    static int[] numbers;
    static List<Integer> book = new ArrayList<Integer>();
    static int[] book2;
    static List<Integer> list2 = new ArrayList<Integer>();  //用于记录空的位置
    static int result = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        k = scanner.nextInt();
        numbers = new int[n];
        book2 = new int[n];
        for(int i=0;i<n;i++){
            numbers[i] = scanner.nextInt();
        }
        for(int i=0;i<n;i++){
            if(numbers[i] != 0){
                book2[numbers[i]-1] = 1;
            }
        }
        for(int i=0;i<n;i++){
            if(book2[i] == 0){
                book.add(i+1);
            }
        }
        //记录numbers中0的位置
        for(int i=0;i<n;i++){
            if(numbers[i] == 0){
                list2.add(i);
            }
        }
        dfs(0);
        System.out.println(result);
    }

    public static void dfs(int k){

        if(k == book.size()-1){
            function1();
            return;
        }
        for(int i=k;i<book.size();i++){
            swap(i,k);
            dfs(k+1);
            swap(i,k);
        }
    }

    public static void swap(int n1,int n2){
        int c = 0;
        c = book.get(n1);
        book.set(n1,book.get(n2));
        book.set(n2,c);

    }


    public static void function1(){
        int k = 0;

        for(int i=0;i<list2.size();i++){
            numbers[list2.get(i)] = book.get(k);
            k++;
        }
        judge();
    }

    //判断
    public static void judge(){
        int count = 0;
        for(int j=0;j<numbers.length-1;j++){
            for(int w=j+1;w<numbers.length;w++){
                if(numbers[j] < numbers[w]){
                    count++;
                }
            }
        }
        if(count == k){
            result++;
        }
    }

}
